package 牛客网_N.动态规划.叠罗汉1_10;

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		String str = in.nextLine();
		String dataStr[] = str.split(" ");
		int[] A = new int[n];
		for(int i = 0; i < n; i++){
			A[i] = Integer.parseInt(dataStr[i]);
		}
		System.out.println(getHeight(A, n));
	}
	
	  public int getHeight2(int[] A, int n) {
	        // write code here
			int[] res = new int[n];
			res[0] = 1;
			int max = 1;
			for(int i = 1; i < n; i++){
	            int max2 = 0;
				for(int j = 0; j <= i; j++){
					if(A[i] > A[j]){
						max2 = res[j] >= max2 ? res[j] : max2;
					}
				}
				res[i] = max2 + 1;
				max = Math.max(max, res[i]);
			}
			return max;
	    }
	
	public static int getHeight(int[] A, int n){
		int[] B = new int[n];
		System.arraycopy(A, 0, B, 0, n);
		int temp = 0;
		for(int i = 0; i < n-1; i++){
			for(int j = 0; j < n-1-i; j++){
				if(B[j] > B[j+1]) {
					temp = B[j];
					B[j] = B[j+1];
					B[j+1] = temp;
				}
			}
		}

		
		int[][] res = new int[n+1][n+1];
		for(int i = 0; i < n; i++){
			res[i][0] = 0;
			res[0][i] = 0;
		}
		
		for(int i = 1; i < n+1; i++){
			for(int j = 1; j < n+1; j++){
				if(A[i-1] == B[j-1]){
					res[i][j] = res[i-1][j-1]+1;
				}else{
					res[i][j] = Math.max(res[i-1][j], res[i][j-1]);
				}
			}
		}
		return res[n][n];
	}
}
